#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
#include<stdlib.h>

int main()
{
  pid_t id = fork();
  if (id == 0)  // 子进程
  {
    printf("i am child process\n");
    exit(66);
  }
  else 
  {
    sleep(5);
    int status = 0;
    pid_t _pid = waitpid(id, &status, 0);
    sleep(5);
    printf("父进程：%d, 子进程: %d, 返回值: %d, 退出信号: %d 退出码: %d coredump：%d\n", getpid(), id, _pid, (status & 0x7f), ((status >> 8) & 0xff), ((status >> 7) & 1));
  }
  return 0;
}
